home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.3 (Developer)…68k, x86, SPARC, PA-RISC] / NeXTSTEP 3.3 Dev Intel.iso / NextDeveloper / Source / GNU / cctools / as / m88k-check.c < prev    next >
C/C++ Source or Header  |  1993-09-09  |  2KB  |  151 lines

  1. #include <stdio.h>
  2. #include "m88k-opcode.h"
  3.  
  4. static int reg(void);
  5. static int creg(void);
  6. static int cnst(void);
  7. static void print_cond(void);
  8. static void print_cmp(void);
  9.  
  10. void
  11. main(
  12. int argc,
  13. char *argv[],
  14. char *envp[])
  15. {
  16.     long i, j;
  17.  
  18.     for(i = 0; i < NUMOPCODES - 1; i++){
  19.         printf("\t%s\t", m88k_opcodes[i].name);
  20.         if(m88k_opcodes[i].op[0].type == NIL)
  21.         printf("\n");
  22.         for(j = 0; j < 3 && m88k_opcodes[i].op[j].type != NIL; j++){
  23.         switch(m88k_opcodes[i].op[j].type){
  24.         case CNST:
  25. #ifdef SIGNED_IMMEDIATES
  26.         case SCNST:
  27. #endif
  28.             printf("0x%04x", cnst() );
  29.             break;
  30.         case REG:
  31.             printf("r%d", reg() );
  32.             break;
  33.         case BF:
  34.             printf("%d<%d>", reg(), reg() );
  35.             break;
  36.         case REGSC:
  37.             printf("[r%d]", reg() );
  38.             break;
  39.         case CRREG:
  40.             printf("cr%d", creg() );
  41.             break;
  42.         case FCRREG:
  43.             printf("fcr%d", creg() );
  44.             break;
  45.         case PCREL:
  46.             printf("undef");
  47.             break;
  48.         case CONDMASK:
  49.             print_cond();
  50.             break;
  51.         case CMPRSLT:
  52.             print_cmp();
  53.             break;
  54.         case ROT:
  55.             printf("<%d>", reg() );
  56.             break;
  57.         case E4ROT:
  58.             printf("<%d>", creg() & ~0x3);
  59.             break;
  60.         case EREG:
  61.             printf("r%d", reg() & ~0x1);
  62.             break;
  63.         case XREG:
  64.             printf("x%d", reg());
  65.             break;
  66.         }
  67.         if(j == 2 || m88k_opcodes[i].op[j+1].type == NIL)
  68.             printf("\n");
  69.         else if(m88k_opcodes[i].op[j+1].type != REGSC)
  70.             printf(",");
  71.         }
  72.     }
  73. }
  74.  
  75. static
  76. int
  77. reg(void)
  78. {
  79.      static int x = 1;
  80.  
  81.     x = (x + 1) & 0x1f;
  82.     return(x);
  83. }
  84.  
  85. static
  86. int
  87. creg(void)
  88. {
  89.      static int x = 1;
  90.  
  91.     x = (x + 1) & 0x3f;
  92.     return(x);
  93. }
  94.  
  95. static
  96. int
  97. cnst(void)
  98. {
  99.      static int x = 1;
  100.  
  101.     x = (x + 1) & 0xffff;
  102.     return(x);
  103. }
  104.  
  105. static
  106. void
  107. print_cond(void)
  108. {
  109.      static int x = 1;
  110.  
  111.     x = (x + 1) & 0x1f;
  112.     switch(x){
  113.     case 0x02:
  114.         printf("eq0");
  115.         break;
  116.     case 0x0d:
  117.         printf("ne0");
  118.         break;
  119.     case 0x01:
  120.         printf("gt0");
  121.         break;
  122.     case 0x0c:
  123.         printf("lt0");
  124.         break;
  125.     case 0x03:
  126.         printf("ge0");
  127.         break;
  128.     case 0x0e:
  129.         printf("le0");
  130.         break;
  131.     default:
  132.         printf("%d", x);
  133.     }
  134. }
  135.  
  136. static
  137. char *cmpslot[] = { "**", "**", "eq", "ne", "gt", "le", "lt", "ge",
  138.             "hi", "ls", "lo", "hs", "be", "nb", "he", "nh" };
  139. static
  140. void
  141. print_cmp(void)
  142. {
  143.      static int x = 1;
  144.  
  145.     x = (x + 1) & 0x1f;
  146.     if(x < 2 || x > 15)
  147.         printf("%d", x);
  148.     else
  149.         printf("%s", cmpslot[x]);
  150. }
  151.